<%-- 
    Document   : content_quicksearch
    Created on : Nov 27, 2011, 11:28:31 PM
    Author     : Ngoc Linh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<div class="main_content_panel" id="box_listproduct">
    <div class="advanced_search_box">
        <form action="advancedsearch.do" method="post">
            <table class="table_fm">
                <tr>
                    <td class="label">Tên sản phẩm</td>
                    <td class="value"><input type="text" name="TenSanPham" value="${requestScope.tenSanPham}"/></td>
                    <td class="error" id="invalid_productname"></td>
                </tr>
                <tr>
                    <td class="label">Danh mục</td>
                    <td class="value">
                        <select name="DanhMuc">
                            <option value="-1" selected="selected">-- Tất cả --</option>
                            <c:forEach var="dm" items="${requestScope.dsDanhMuc}">
                                <option value="${dm.maDanhMuc}" <c:if test="${requestScope.danhMuc eq dm.maDanhMuc}">selected="selected"</c:if> >${dm.tenDanhMuc}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td class="error"></td>
                </tr>
                <tr>
                    <td class="label">Giá thấp nhất</td>
                    <td class="value">
                        <select name="GiaMin">
                            <option value="-1">Nhỏ hơn 500,000 VNĐ</option>
                            <c:forEach var="price" items="${requestScope.listMinPrice}">
                                <option value="${price}" <c:if test="${requestScope.giaMin eq price}">selected="selected"</c:if> ><fmt:formatNumber type="number" value="${price}" maxFractionDigits="0"></fmt:formatNumber> VNĐ</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td class="error"></td>
                </tr>
                <tr>
                    <td class="label">Giá cao nhất</td>
                    <td class="value">
                        <select name="GiaMax">
                            <c:forEach var="price" items="${requestScope.listMaxPrice}">
                                <option value="${price}" <c:if test="${requestScope.giaMax eq price}">selected="selected"</c:if> ><fmt:formatNumber type="number" value="${price}" maxFractionDigits="0"></fmt:formatNumber> VNĐ</option>
                            </c:forEach>
                            <option value="-1">Lớn hơn 80,000,000 VNĐ</option>
                        </select>
                    </td>
                    <td class="error"></td>
                </tr>
                <tr>
                    <td class="label">&nbsp;</td>
                    <td class="value" style="padding-top:10px;">
                        <input class="btn_cm_common btn_option" type="submit" name="sign_up" value="Tìm kiếm" />
                    </td>
                    <td class="error">&nbsp;</td>
                </tr>
            </table>
        </form>
    </div>
    <p class="top_main_content_panel">
        Kết quả tìm kiếm nâng cao - ${requestScope.dsSP.size()} sản phẩm
    </p>
    <div class="content_main_content_panel">
        <c:if test="${numberPages > 0}">
            <div class="paging">
                <ul>
                    <c:forEach var="i" begin="1" end="${numberPages}">
                        <c:url value="advancedsearch.do" var="listproduct_link">
                            <c:param name="numpro_perpage" value="${numpro_perpage}" />
                            <c:param name="page" value="${i}" />
                        </c:url>
                        <c:if test="${requestScope.page eq i}">
                            <li class="current_page">    
                                <a href="<c:out value="${listproduct_link}" />">${i}</a>
                            </li>
                        </c:if>
                        <c:if test="${requestScope.page ne i}">
                            <li>    
                                <a href="<c:out value="${listproduct_link}" />">${i}</a>
                            </li>
                        </c:if>
                    </c:forEach>

                </ul>

                <form name="frmNumPro_PerPage" action="advancedsearch.do" method="post">
                    <p class="select_numperpage">                                
                        <span>Hiển thị </span>
                        <select name="numpro_perpage" id="numpro_perpage" onchange="submit()">
                            <option 
                                <c:if test="${numpro_perpage == 3}"> selected="selected" </c:if>
                                value="3">
                                3
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == 6}"> selected="selected" </c:if>
                                value="6">
                                6
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == 12}"> selected="selected" </c:if>
                                value="12">
                                12
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == -1}"> selected="selected" </c:if>
                                value="-1">
                                Tất cả
                            </option>
                        </select>
                        <input name="maDanhMuc" type="hidden" id="maDanhMuc" value="${maDanhMuc}" />
                        <input type="hidden" name="page" value="1"/>
                        <span> sản phẩm trên trang</span>
                    </p>
                </form>                            
            </div>

            <div class="list_products">
                <c:forEach var="sp" items="${dsSP}">
                    <div class="product_item">
                        <c:url value="product.do" var="linkDetailPro">
                            <c:param name="masp" value="${sp.maSanPham}"></c:param>
                        </c:url>
                        <p class="name_product">    
                            <a href="${linkDetailPro}" title="Xem chi tiết">
                                ${sp.tenSanPham}
                            </a>                                
                        </p>
                        <p class="image_product">
                            <a href="${linkDetailPro}" title="Xem chi tiết">
                                <img src="${sp.hinhMoTa}" alt="${sp.tenSanPham}" width="110px" height="110px" />
                            </a>
                        </p>
                        <div class="info_product">
                            <p class="timedown_product" id="countdown_${sp.maSanPham}">
                                <fmt:formatDate value="${sp.ngayDang}" pattern="dd/MM/yyyy HH:mm"></fmt:formatDate>
                            </p>
                            <p class="timeend_product">
                                <fmt:formatDate value="${sp.ngayHetHan}" pattern="dd/MM/yyyy HH:mm:ss"></fmt:formatDate>
                            </p>
                            <p class="price_product">
                                <fmt:formatNumber pattern="###,###" value="${sp.giaHienTai}"></fmt:formatNumber><span>đ</span>
                            </p>
                            <fmt:formatDate pattern="MM/dd/yyyy HH:mm:ss" value="${sp.ngayHetHan}" var="dateEnd"></fmt:formatDate>
                        </div>                                
                        <p class="datgia">
                            <a href="${linkDetailPro}"> <img src="images/btn_datgia.png" alt="" /></a>
                        </p>
                    </div>
                    <script type="text/javascript"> 
                        GetCount(new Date('${dateEnd}'), 'countdown_${sp.maSanPham}' );
                    </script>
                </c:forEach>
            </div>
            <div class="paging">
                <ul>
                    <c:forEach var="i" begin="1" end="${numberPages}">
                        <c:url value="advancedsearch.do" var="listproduct_link">
                            <c:param name="numpro_perpage" value="${numpro_perpage}" />
                            <c:param name="page" value="${i}" />
                            <c:param name="maDanhMuc" value="${maDanhMuc}" />
                        </c:url>
                        <c:if test="${requestScope.page eq i}">
                            <li class="current_page">    
                                <a href="<c:out value="${listproduct_link}" />">${i}</a>
                            </li>
                        </c:if>
                        <c:if test="${requestScope.page ne i}">
                            <li>    
                                <a href="<c:out value="${listproduct_link}" />">${i}</a>
                            </li>
                        </c:if>
                    </c:forEach>
                </ul>

                <form name="frmNumPro_PerPage" action="advancedsearch.do" method="post">
                    <p class="select_numperpage">                                
                        <span>Hiển thị </span>
                        <select name="numpro_perpage" id="numpro_perpage" onchange="submit()">
                            <option 
                                <c:if test="${numpro_perpage == 3}"> selected="selected" </c:if>
                                value="3">
                                3
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == 6}"> selected="selected" </c:if>
                                value="6">
                                6
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == 12}"> selected="selected" </c:if>
                                value="12">
                                12
                            </option>
                            <option 
                                <c:if test="${numpro_perpage == -1}"> selected="selected" </c:if>
                                value="-1">
                                Tất cả
                            </option>
                        </select>
                        <input name="maDanhMuc" type="hidden" id="maDanhMuc" value="${maDanhMuc}" />
                        <input type="hidden" name="page" value="1"/>
                        <span> sản phẩm trên trang</span>
                    </p>
                </form>                            
            </div>
        </c:if>

        <c:if test="${numberPages < 1}">
            <li>    
                Không tìm thấy sản phẩm này.
            </li>
        </c:if>
    </div>
</div>
